/**
 * Project oo_thread
 */


#include "Condition.h"
#include "Mutex.h"
/**
 * Condition implementation
 */

/**
 * @param Mutex &
 */
Condition::Condition(Mutex & mux)
:_mutex(mux)
{
    pthread_cond_init(&_cond, nullptr);

}

Condition::~Condition()
{
    pthread_cond_destroy(&_cond);
}

/**
 * @return void
 */
void Condition::wait() {
    pthread_cond_wait(&_cond, _mutex.getMutexptr());
}

/**
 * @return void
 */
void Condition::notify() {
    pthread_cond_signal(&_cond);
}

/**
 * @return void
 */
void Condition::notifyAll() {
    pthread_cond_broadcast(&_cond);
}

